package array

import "soluty.cc/go/godash/internal"

// 移除数组中predicate（断言）返回为真值的所有元素，原数组会被修改, 并返回移除元素组成的数组
func Remove(array *[]T, predicate func(value T, index int, array []T) bool) []T {
	var ret []T
	var indexes []int
	for index, value := range *array {
		if predicate(value, index, *array) {
			ret = append(ret, value)
			indexes = append(indexes, index)
		}
	}
	*array = internal.BasePullAt(*array, indexes)
	return ret
}
